# -*- coding: utf-8 -*-
# @Time : 2022/6/15 上午10:00
# @Author : wyf
# @FileName: chromedriver_demo.py
# @Email: yunfei.wang@innvote.com
# 操作谷歌浏览器
# http://chromedriver.storage.googleapis.com/index.html

from selenium import webdriver
from selenium.webdriver.common.by import By

browser = webdriver.Chrome()

# 请求百度
browser.get("https://www.baidu.com/")

# 输入框
kw = browser.find_element(By.ID, "kw")
kw.send_keys("python")  # 输入 python

# 按钮
btn = browser.find_element(By.ID, "su")
btn.click()  # 点击搜索按钮

# 提取页面
text = browser.page_source.encode("utf-8", "ignore")
print(text)

# 提取 cookie
cookie = browser.get_cookies()
print("cookie", cookie)
# url
url = browser.current_url
print(url)

browser.close()



